import csv


# %%
def writeToCsv(outPath, data, title=None):
    # 默认自动换行,所以数据会隔一行,要newline=''
    csvFile = open(outPath, 'w+', newline='')

    writer = csv.writer(csvFile)
    # 写入标题头，如果不需要注释即可
    if title:
        writer.writerow(title)
    # 写自己实际数据
    for item in data:
        writer.writerow(item)

    csvFile.close()
    print("finished")
